//
//  QcDoctorInfoController.m
//  QcMedical1
//
//  Created by jiawen Du on 2016/12/22.
//  Copyright © 2016年 jiawen Du. All rights reserved.
//

#import "QcDoctorInfoController.h"
#import "MCFireworksButton.h"

@interface QcDoctorInfoController ()
@property (weak, nonatomic) IBOutlet UISegmentedControl *segmenteCon;
@property (weak, nonatomic) IBOutlet UITextView *textV;

@property (weak, nonatomic) IBOutlet MCFireworksButton *likeButton;

@end

@implementation QcDoctorInfoController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self texiao];

    [self setupUI];
    //赋值
    [self getData];
    
    if (_selected == YES) {
    [self.likeButton setImage:[UIImage imageNamed:@"4"] forState:UIControlStateNormal];
    }
}

- (void)getData{
    
    [self.doctorPic sd_setImageWithURL:[NSURL URLWithString:_ApplyModel.doctor_portrait]placeholderImage:[UIImage imageNamed:@"bb"]];
    
    self.docName.text = _ApplyModel.doctor_name;
    
    self.flag.text = _ApplyModel.banner.description;
    
    self.flower.text = _ApplyModel.flower.description;
    
    self.zan.text = _ApplyModel.operation_count.description;
    
    self.occupation.text = _ApplyModel.doctor_title_name;
    
    self.hospital.text = _ApplyModel.doctor_hospital_name;
}

- (void)setupUI {
 
    
    self.navigationItem.title = @"医生基本信息";
    
    UIButton *button = [[UIButton alloc]init];
    
    [self.view addSubview:button];
    
    [button setTitle:@"咨询医生" forState:UIControlStateNormal];

    button.backgroundColor = [UIColor colorWithRed:69/255.0 green:178/255.0 blue:175/255.0 alpha:1];
    
    [button mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.bottom.equalTo(self.view).mas_offset(-10);
        
        make.left.equalTo(self.view).mas_offset(10);
        
        make.right.equalTo(self.view).mas_offset(-10);
        
        make.height.mas_offset(50);
    }];
    
    [button addTarget:self action:@selector(clickConsultButton :) forControlEvents:UIControlEventTouchUpInside];
    self.segmenteCon.selectedSegmentIndex = 0;

    self.textV.text = @"看病观看弹手脉. \n阴阳调和结医理.\n若问此篇何人作.\n齐云山中老中医.\n";
    
    
    self.textV.userInteractionEnabled = NO;
    
    self.textV.font =[UIFont systemFontOfSize:18];
    
}

- (void)clickConsultButton:(UIButton *)button {
    
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES];
    hud.mode = MBProgressHUDModeText;
    hud.label.text = NSLocalizedString(@"该医生已下架~!", @"HUD message title");

    [hud hideAnimated:YES afterDelay:1.f];
    
    
    
}


- (IBAction)clickLeft:(id)sender {
           switch (self.segmenteCon.selectedSegmentIndex) {
        case 0:
            self.textV.text = @"看病观看弹手脉, \n阴阳调和结医理,\n若问此篇何人作,\n齐云山中老中医.\n";
            break;
        case 1:
            self.textV.text = @"老中医，男，1942年出生，湖南省石门县人，湖南中医药大学教授，研究生导师，全国第四批、第五批老中医药专家学术经验继承人指导老师，中医药师承教育博士生导师，湖南省名中医，湖南中医药大学第一附属医院学术顾问。历任湖南中医药大学内经教研室主任，中医经典古籍教研室主任，学术委员会委员，并任中华中医药学会内经专业委员会会员，内经教学研究会委员。";
   
            break;
        default:
            break;
    }
    
}

#pragma mark
#pragma mark - 点赞按钮特效
- (IBAction)clickZan:(id)sender {
    
    _selected = !_selected;
    if (_selected) {
        [self.likeButton popOutsideWithDuration:0.5];
        //选中状态下的图
        [self.likeButton setImage:[UIImage imageNamed:@"4"] forState:UIControlStateNormal];
        [self.likeButton animate];
    }
    else {
        [self.likeButton popInsideWithDuration:0.4];
        //非选中状态下的图
        [self.likeButton setImage:[UIImage imageNamed:@"3"] forState:UIControlStateNormal];
    }
    
    [[NSNotificationCenter defaultCenter]postNotificationName:@"zan" object:@(self.selected)];
    
 //NSLog(@"info中的赞%d",self.selected);
    
}

- (void)texiao {
    
    
    //特效颜色
    self.likeButton.particleImage = [UIImage imageNamed:@"4"];
    self.likeButton.particleScale = 0.05;
    self.likeButton.particleScaleRange = 0.02;
}

@end
